package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringCompletionOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringCompletionOrderDetailBean;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringCompletionOrderDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringCompletionOrderDetailModel;

/**
 * Created by tony on 2018/5/11.
 */

public class EngineeringCompletionOrderDetailPresenter {
    private IEngineeringCompletionOrderDetailView view;
    private IEngineeringCompletionOrderDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringCompletionOrderDetailPresenter(IEngineeringCompletionOrderDetailView view) {
        this.view = view;
        this.model = new EngineeringCompletionOrderDetailModel();
    }

    public void getEngineeringCompletionOrderDetail() {


        model.getEngineeringCompletionOrderDetail(view.getOrderId(), new EngineeringCompletionOrderDetailModel.EngineeringCompletionOrderDetailListener() {
            @Override
            public void getEngineeringCompletionOrderDetailSuccessed(final EngineeringCompletionOrderDetailBean engineeringCompletionOrderDetailBean) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringCompletionOrderDetailSuccessed(engineeringCompletionOrderDetailBean);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getEngineeringCompletionOrderDetailFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringCompletionOrderDetail(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
